source('plotfdp.R')

xs <- rep(0, 100)
ys <- rep(0, 100)
xs_fora <- NULL
ys_fora <- NULL

total <- 0
i <- 1
j <- 1
while(i <= 100) {
	xs[i] <- runif(1, xlim[1], xlim[2])
	ys[i] <- runif(1, ylim[1], ylim[2])
	y <- fdp(xs[i])
	if(ys[i] <= y)
		i <- i+1
	else {
		xs_fora[j] <- xs[i]
		ys_fora[j] <- ys[i]
		j <- j+1
	}
	total <- total+1
}

points(xs, ys,
	pch='x', cex=.75,
	col=rgb(0,0,0,1), lwd=2)

points(xs_fora, ys_fora,
	pch='x', cex=.75,
	col=rgb(0,0,0,.2), lwd=2)

print(paste('para cada nro tive q fazer estas tentativas:', total/100))

